home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / play / tracker_4_31.lzh / tracker / autoinit.c < prev    next >
C/C++ Source or Header  |  1995-02-21  |  1KB  |  61 lines

  1. /* autoinit.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4.  
  5. /* $Id: autoinit.c,v 4.13 1995/02/21 17:54:32 espie Exp $ 
  6.  * $Log: autoinit.c,v $
  7.  * Revision 4.13  1995/02/21  17:54:32  espie
  8.  * Internal problem: buggy RCS. Fixed logs.
  9.  *
  10.  * Revision 4.7  1995/02/01  16:39:04  espie
  11.  * Includes moved to defs.h
  12.  *
  13.  */
  14.  
  15.  
  16. #include "defs.h"
  17. #include "extern.h"
  18.  
  19. ID("$Id: autoinit.c,v 4.13 1995/02/21 17:54:32 espie Exp $")
  20.  
  21. LOCAL struct clist
  22.     {
  23.     struct clist *next;
  24.     void (*func) P((void));
  25.     } *list = 0;
  26.     
  27.  
  28. void at_end(cleanup)
  29. void (*cleanup) P((void));
  30.     {
  31. #ifdef USE_AT_EXIT
  32.     atexit(cleanup);
  33. #else
  34.     struct clist *new;
  35.     new = (struct clist *)malloc(sizeof(struct clist));
  36.     if (!new)
  37.         {
  38.         (*cleanup)();
  39.         end_all("Allocation problem");
  40.         }
  41.     new->next = list;
  42.     new->func = cleanup;
  43.     list = new;
  44. #endif
  45.     }
  46.     
  47. void end_all(s)
  48. char *s;
  49.     {
  50. #ifndef USE_AT_EXIT
  51.     struct clist *p;
  52. #endif
  53.     if (s)
  54.         notice(s);
  55. #ifndef USE_AT_EXIT
  56.     for (p = list; p; p = p->next)
  57.         (p->func)();            /* don't bother freeing (malloc) */
  58. #endif
  59.     exit(s ? 10 : 0);
  60.     }
  61.